﻿namespace SampleApplication.Library
{
    using System;
    using Codeplex.Unity.AutoRegister;
    using Microsoft.Practices.Unity;

    // custom export
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
    public class CustomExportAttribute : UnityExportAttribute
    {
        public CustomExportAttribute()
        {
            // custom property injection
            this.InjectionMembers = new[]
            {
                // injection ViewModel instance.
                new InjectionProperty("DataContext", new ResolvedParameter<ViewModel>())
            };
        }
    }

    // custom export
    [CustomExport]
    // custom InjectionMemberProvider
    [UnityExport(
        Name = "InjectionMemberProviderSample", 
        InjectionMemberProvider = typeof(InjectionDataContextProvider<ViewModel>))]
    public class Control
    {
        // !!no set Dependency annotation!!
        public object DataContext { get; set; }
    }

    [UnityExport]
    public class ViewModel
    {
    }
}
